package com.logger.handlers;

import android.util.Log;

import com.logger.Level;
import com.logger.LogMessage;

/**
 * 输出到控制台
 * Created by chenxunlin01 on 2017/1/16.
 */

public class ConsoleHandler extends AHandler {

    @Override
    public void handler(LogMessage msg, String log) throws Exception {
        if (log == null) {
            throw new Exception("ConsoleHandler log is null");
        }

        String tag = msg.getTag();
        Level level = msg.getLevel();
        if (level.equals(Level.VERBOSE)) {
            Log.v(tag, log);
        } else if (level.equals(Level.INFO)) {
            Log.i(tag, log);
        } else if (level.equals(Level.DEBUG)) {
            Log.d(tag, log);
        } else if (level.equals(Level.WARN)) {
            Log.w(tag, log);
        } else if (level.equals(Level.ERROR)) {
            Log.e(tag, log);
        }
    }
}
